<?php
/**
 * Created by 784855684@qq.com.
 * User: linzh
 * Date: 7/30/17
 * Time: 2:54 PM
 */


namespace inframe\test\core;


use inframe\core\Encryption;
use inframe\helper\Chars;
use inframe\test\Wsunit;

class EncryptionTest extends Wsunit
{
    public function testrun()
    {
        $count = 10000;
        $engine = Encryption::getInstance('thishdiushfdisanfuwebvjxbsdur89w75238thes7');
        $engine2 = Encryption::getInstance('thishdiushfdisanfuwebvjxbsdur89w75238thes7');
        while ($count--) {
            $str = Chars::random(100);
            $enstr = $engine->encrypt($str);
            $this->assertEquals($str, $engine2->decrypt($enstr));
        }
        $engine3 = Encryption::getInstance('Xthishdiushfdisanfuwebvjxbsdur89w75238thes7X');
        $str = Chars::random(100);
        $enstr = $engine->encrypt($str);
        $this->assertNotEquals($str, $engine3->decrypt($enstr));
    }
}